<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('详细出库')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-fOutbound-edit" th:object="${fOutbound}">
            <input name="outId" th:field="*{outId}" type="hidden">
            <input name="thingId" th:field="*{thingId}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">物品目录：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input readonly="readonly" required name="thingName" th:field="*{thingName}"  id="treeName" type="text" placeholder="请选择物品" class="form-control">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                    <span style="color: red" id="tishi"></span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">物品名称：</label>
                <div class="col-sm-8">
                    <input name="createName" th:field="*{createName}" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">数量：</label>
                <div class="col-sm-8">
                    <input d="shuliang" name="shuliang" th:field="*{shuliang}" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">人均消耗：</label>
                <div class="col-sm-8">
                    <input readonly="readonly" name="pingjunSunhao" th:field="*{pingjunSunhao}" class="form-control" type="text">
                </div>
            </div>
            <div id="freasonDiv" style="display: none" class="form-group">
                <label class="col-sm-3 control-label" style="color: red">超出平均单价理由：</label>
                <div class="col-sm-8">
                    <textarea id="freason" name="freason" class="form-control">[[*{freason}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">出库类型：</label>
                <div class="col-sm-8">
                    <select name="outboundType" class="form-control m-b" th:with="type=${@dict.getType('f_outbound_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{outboundType}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">出库时间：</label>
                <div class="date col-sm-8">
                    <input name="outTime" type="text" th:value="*{#dates.format(outTime, 'yyyy-MM-dd')}" class="form-control" id="outTime" placeholder="yyyy-MM-dd" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                </div>
            </div>

            <div id="examineBy" style="display: none;" class="form-group">
                <label class="col-sm-3 control-label">审批人：</label>
                <div class="col-sm-8">
                    <p class="form-control-plaintext" th:text="*{examineBy}"></p>
                </div>
            </div>
            <div id="examineRemark" style="display: none;" class="form-group">
                <label class="col-sm-3 control-label">审批意见：</label>
                <div class="col-sm-8">
                    <p class="form-control-plaintext" th:text="*{examineRemark}"></p>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var fOutbound = [[${fOutbound}]]
        if(fOutbound.examineRemark){
            $("#examineRemark").css("display","block")
        }
        if(fOutbound.examineBy){
            $("#examineBy").css("display","block")
        }
        if(fOutbound.freason){
            $("#freasonDiv").css("display","block")
        }

        var prefix = ctx + "financial/fOutbound";
        $("#form-fOutbound-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-fOutbound-edit').serialize());
            }
        }

        function selectThingTree() {
            var treeId = $("#treeId").val();
            var deptId = $.common.isEmpty(treeId) ? "0" : $("#treeId").val();
            var url = ctx + "financial/fThing/selectFThingTree/" + deptId;
            var options = {
                title: '选择物品',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }
        function doSubmit(index, layero){
            var body = $.modal.getChildFrame(index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            $.modal.close(index);
            wupin();
        }

        function wupin() {
            var randomNum = Math.floor(Math.random() * (100 - 1 + 1)) + 1;
            $("#tishi").html("平均消耗"+randomNum)
        }

    </script>
</body>
</html>